﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AccountModule.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="AccountModule" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Modules.Core.Account
{
    using Hisaab.Client.Common;
    using Hisaab.Client.Modules.Core.Account.View;

    using Microsoft.Practices.Prism.Modularity;
    using Microsoft.Practices.Prism.Regions;
    using Microsoft.Practices.Unity;

    using ServiceLocator = Microsoft.Practices.ServiceLocation.ServiceLocator;

    /// <summary>
    /// Defines the <seealso cref="AccountModule"/> type.
    /// </summary>
    public class AccountModule : IModule
    {
        /// <summary>
        /// Member variable AccountEditor
        /// </summary>
        public const string AccountEditor = "AccountEditor";

        /// <summary>
        /// Member variable AccountModule
        /// </summary>
        public const string ModuleName = "AccountModule";

        /// <summary>
        /// Member variable AccountView
        /// </summary>
        public const string AccountTab = "AccountsTab";

        /// <summary>
        /// Member variable AccountsView
        /// </summary>
        public const string AccountsView = "Accounts";

        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
            regionManager.RegisterViewWithRegion(Regions.HomeAddMediumGroup, typeof(AccountAddButton));
            regionManager.RegisterViewWithRegion(Regions.HomeListGroup, typeof(AccountViewButton));
            regionManager.RegisterViewWithRegion(Regions.NavigationRegion, typeof(AccountNavigation));
            regionManager.RegisterViewWithRegion(Regions.RightNavigationRegion, typeof(AccountSideBar));

            var container = ServiceLocator.Current.GetInstance<IUnityContainer>();
            container.RegisterType<object, Accounts>(AccountsView);
            container.RegisterType<object, AccountEditor>(AccountEditor);
            container.RegisterType<object, AccountsTab>(AccountTab);
        }
    }
}